import java.util.Stack;

/**
 * @author Sebastian
 * @version 2.0
 * @date 2024/8/5 11:16
 */
// 图书整理II
// 用两个栈实现队列
    //https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/description/
public class Solution125 {
    Stack<Integer> stack1;
    Stack<Integer> stack2;
    public Solution125() {
        stack1 = new Stack<Integer>();
        stack2 = new Stack<Integer>();
    }

    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        if (stack2.isEmpty()) {
            if (stack1.isEmpty()) return -1;
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
            return stack2.pop();
        } else {
            return stack2.pop();
        }
    }
}
